
function isAllAlphabet(argvalue) {
        argvalue = argvalue.toString();
        var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var startFrom = 0;
        
        for (var n = startFrom; n < argvalue.length; n++) {
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
        }
        return true;
    }
    
function isAllDigits(argvalue) {
        argvalue = argvalue.toString();
        var validChars = "0123456789";
        var startFrom = 0;
        if (argvalue.substring(0, 2) == "0x") {
           validChars = "0123456789abcdefABCDEF";
           startFrom = 2;
        } else if (argvalue.charAt(0) == "0") {
           validChars = "01234567";
           startFrom = 1;
        } else if (argvalue.charAt(0) == "-") {
            startFrom = 1;
        }

        for (var n = startFrom; n < argvalue.length; n++) {
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
        }
        return true;
    }

function isAllNumber(argvalue){
      argvalue = argvalue.toString();
      var validChars = "0123456789.";
      var startFrom = 0;
      var i = 0;

      for (var n = startFrom; n < argvalue.length; n++) {
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1)return false;
            if ("."==argvalue.substring(n, n+1) )  i++;
            if (i>1) return false;
      }
      return true;
}

function isAlphabetNumber(argvalue){
	argvalue = argvalue.toString();
        var validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.";
        var startFrom = 0;
        
        for (var n = startFrom; n < argvalue.length; n++) {
            if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
        }
        return true;
}
 
function isEmail(emailStr) {
       if (emailStr.length == 0) {
           return true;
       }
       var emailPat=/^(.+)@(.+)$/;
       var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
       var validChars="\[^\\s" + specialChars + "\]";
       var quotedUser="(\"[^\"]*\")";
       var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
       var atom=validChars + '+';
       var word="(" + atom + "|" + quotedUser + ")";
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
       var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
       var matchArray=emailStr.match(emailPat);
       if (matchArray == null) {
           return false;
       }
       var user=matchArray[1];
       var domain=matchArray[2];
       if (user.match(userPat) == null) {
           return false;
       }
       var IPArray = domain.match(ipDomainPat);
       if (IPArray != null) {
           for (var i = 1; i <= 4; i++) {
              if (IPArray[i] > 255) {
                 return false;
              }
           }
           return true;
       }
       var domainArray=domain.match(domainPat);
       if (domainArray == null) {
           return false;
       }
       var atomPat=new RegExp(atom,"g");
       var domArr=domain.match(atomPat);
       var len=domArr.length;
       if ((domArr[domArr.length-1].length < 2) ||
           (domArr[domArr.length-1].length > 3)) {
           return false;
       }
       if (len < 2) {
           return false;
       }
       return true;
    }

function FormNavPrint(frm) {
  noprint.style.display="none"; 
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }

  var formData=new Array();
  for (var ii = 0; ii < frm.elements.length; ii++) {
     if (frm.elements[ii].name != "" && frm.elements[ii].name.substring(0,9) == "FB_FIELD_"){
     	formData[ii] = new Array();
     	formData[ii][0]=frm.elements[ii].value;
     	formData[ii][1]=frm.elements[ii].disabled;
        frm.elements[ii].disabled = false;
     }

  } 
  var bVersion = parseInt(navigator.appVersion);
  if (bVersion >= 4) {
    window.print();
  } else {
    alert("This browser doesn't support print function.");
  }

  for (var ii = 0; ii < frm.elements.length; ii++) {
     if (frm.elements[ii].name != "" && frm.elements[ii].name.substring(0,9) == "FB_FIELD_"){
     	frm.elements[ii].value=formData[ii][0];
        frm.elements[ii].disabled = formData[ii][1];
     }
  }   
 noprint.style.display=""; 
}


function OpToggleSelectAllNone1(cb, frm) {
  if (cb.checked) {
    OpSelectAll1(frm);
  } else {
    OpSelectNone1(frm);
  }
}

function OpSelectAll1(frm) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID1") {
      frm.elements[i].checked = true;
    }
  }
  return(false);
} // end of the 'OpSelectAll()' function

function OpSelectNone1(frm) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID1") {
      frm.elements[i].checked = false;
    }
  }
  return(false);
}  // end of the 'OpSelectNone()' function


function ToggleDefaultCheckbox1(theRecordID) {
  var chkAry = FindObj("basicSelectedID1");

  if (chkAry) {
    if (chkAry[0]) {
      var allCheckFlag = true;
      for (var loopCnt = 0; loopCnt < chkAry.length; loopCnt++) {
        if (chkAry[loopCnt].value == theRecordID) {
          chkAry[loopCnt].checked = !chkAry[loopCnt].checked;
        }
        if (!chkAry[loopCnt].checked) {
          allCheckFlag = false;
        }
      }
      if (chkAry[0].form.PARADM_CB_ALL_NONE1) {
        chkAry[0].form.PARADM_CB_ALL_NONE1.checked = allCheckFlag;
      }
    } else {
      chkAry.checked = !chkAry.checked;
      if (chkAry.form.PARADM_CB_ALL_NONE1) {
        chkAry.form.PARADM_CB_ALL_NONE1.checked = chkAry.checked;
      }
    }
  }
}

function SetTableRowColor1(theRow, theRowNum, theAction, theRecordID, theAlterRowFlag) {
  if (!LIST_EFFECT_ENABLE) {
    return;
  }

  var theCells = null;
  var thePointerColor = "#B5D2EA";
  var theMarkColor = "#FFCC99";
  var theDefaultColor = "#EEEEEE";
  if (theRowNum % 2 == 0 || theAlterRowFlag) {
    theDefaultColor = "#FFFFFF";
  }

  // 1. Pointer and mark feature are disabled or the browser can't get the
  //  row -> exits
  if ((thePointerColor == '' && theMarkColor == '')
    || typeof(theRow.style) == 'undefined') {
    return false;
  }

  // 2. Gets the current row and exits if the browser can't get it
  if (typeof(document.getElementsByTagName) != 'undefined') {
    theCells = theRow.getElementsByTagName('td');
  }
  else if (typeof(theRow.cells) != 'undefined') {
    theCells = theRow.cells;
  }
  else {
    return false;
  }

  // 3. Gets the current color...
  var rowCellsCnt  = theCells.length;
  var domDetect  = null;
  var currentColor = null;
  var newColor   = null;
  // 3.1 ... with DOM compatible browsers except Opera that does not return
  //     valid values with "getAttribute"
  if (typeof(window.opera) == 'undefined'
    && typeof(theCells[0].getAttribute) != 'undefined') {
    currentColor = theCells[0].getAttribute('bgcolor');
    domDetect  = true;
  }
  // 3.2 ... with other browsers
  else {
    currentColor = theCells[0].style.backgroundColor;
    domDetect  = false;
  } // end 3

  // 4. Defines the new color
  // 4.1 Current color is the default one
  if (!currentColor || currentColor == ''
    || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {  
    if (theAction == 'over' && thePointerColor != '') {
      newColor        = thePointerColor;
    }
    else if (theAction == 'click' && theMarkColor != '' ) {
      newColor        = theMarkColor;
      g_marked_row1[theRowNum] = true;
      ToggleDefaultCheckbox1(theRecordID);
    }
  }
  // 4.1.2 Current color is the pointer one
  else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
       && (typeof(g_marked_row1[theRowNum]) == 'undefined' || !g_marked_row1[theRowNum]) ) {            
    if (theAction == 'out') {
      newColor        = theDefaultColor;
    }
    else if (theAction == 'click' && theMarkColor != '' ) {
      newColor        = theMarkColor;
      g_marked_row1[theRowNum] = true;
      ToggleDefaultCheckbox1(theRecordID);
    }
  }
  // 4.1.3 Current color is the marker one
  else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
    if (theAction == 'click') {
      newColor        = (thePointerColor != '')
                  ? thePointerColor
                  : theDefaultColor;
      g_marked_row1[theRowNum] = ((typeof(g_marked_row1[theRowNum]) == 'undefined' || !g_marked_row1[theRowNum]) )
                  ? true
                  : null;                
      ToggleDefaultCheckbox1(theRecordID);
    }
  } // end 4
    
  // 5. Sets the new color...
  if (newColor) {
    var c = null;
    // 5.1 ... with DOM compatible browsers except Opera
    if (domDetect) {
      for (c = 0; c < rowCellsCnt; c++) {
        theCells[c].setAttribute('bgcolor', newColor, 0);
      } // end for
    }
    // 5.2 ... with other browsers
    else {
      for (c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = newColor;
      }
    }
  } // end 5

  return true;
} // end of the 'SetTableRowColor()' function



